FROM python:3.9.1

WORKDIR /src

ARG SERVICE_PORT
ARG SRC_DIR
ARG TERMINUSDB_SERVER_PASSWORD
ARG TERMINUSDB_SERVER_URL
ARG TERMINUSDB_SERVER_TEAM
ARG TERMINUSDB_SERVER_DB
ARG BOT_KM_SERVICE_CONFIG
ARG GENERATIVE_SERVICE_URL
ARG GENERATIVE_SERVICE_CONFIG
ARG GENERATIVE_SERVICE_TIMEOUT
ARG SENTENCE_RANKER_URL
ARG SENTENCE_RANKER_TIMEOUT
ARG RELEVANT_KNOWLEDGE_THRESHOLD
ARG ENVVARS_TO_SEND
ARG USE_BOT_KG_DATA

ENV SERVICE_PORT=$SERVICE_PORT
ENV TERMINUSDB_SERVER_PASSWORD=$TERMINUSDB_SERVER_PASSWORD
ENV TERMINUSDB_SERVER_URL=$TERMINUSDB_SERVER_URL
ENV TERMINUSDB_SERVER_TEAM=$TERMINUSDB_SERVER_TEAM
ENV TERMINUSDB_SERVER_DB=$TERMINUSDB_SERVER_DB
ENV BOT_KM_SERVICE_CONFIG=$BOT_KM_SERVICE_CONFIG
ENV GENERATIVE_SERVICE_URL=$GENERATIVE_SERVICE_URL
ENV GENERATIVE_SERVICE_CONFIG=$GENERATIVE_SERVICE_CONFIG
ENV GENERATIVE_SERVICE_TIMEOUT=$GENERATIVE_SERVICE_TIMEOUT
ENV SENTENCE_RANKER_URL=$SENTENCE_RANKER_URL
ENV SENTENCE_RANKER_TIMEOUT=$SENTENCE_RANKER_TIMEOUT
ENV RELEVANT_KNOWLEDGE_THRESHOLD=$RELEVANT_KNOWLEDGE_THRESHOLD
ENV ENVVARS_TO_SEND=$ENVVARS_TO_SEND
ENV USE_BOT_KG_DATA=$USE_BOT_KG_DATA

RUN pip install -U pip wheel setuptools

COPY ./annotators/bot_knowledge_memorizer/requirements.txt .
RUN pip install --upgrade pip && \
    pip install --no-cache -r /src/requirements.txt && \
    python -m nltk.downloader wordnet && \
    pip install git+https://github.com/deeppavlov/custom_kg_svc.git@feat/support_index
    
COPY $SRC_DIR .


CMD gunicorn --workers=1 server:app -b 0.0.0.0:$SERVICE_PORT